;(function(){
    // 轮播
    {
        new Swiper('.swiper-container',{
            height: 402,
            autoplay: true,
            loop: true,
            pagination: {
                el: '.swiper-pagination',
                clickable: true
            }
        })
        new Swiper('.news-swiper-container',{
            height: 350,
            width: 500,
            autoplay: true,
            loop: true,
            pagination: {
                el: '.swiper-pagination',
                clickable: true,
            }
        })
    }

    // 热门培训切换
    {
        $('.course-header-rgt').click(function(){
            var liHieght = $('.course-header-lf li').height();
            var allHeight = $('.course-header-lf ul').height();
            var num = Math.round(allHeight / liHieght);
            var currentPosition = Math.round(Math.abs($('.course-header-lf ul').css('top').slice(0,-2)) / liHieght) || 0;
            console.log(currentPosition,num)
            if(currentPosition === (num-1)){
                $('.course-header-lf ul').css({'top':0});
            }else{
                var pos = (currentPosition+1)*liHieght; 
                pos = pos > 0 ? -pos : pos;
                $('.course-header-lf ul').css({'top':(pos) + 'px'});
            }
        });
    }

    // 新闻切换
    {
        $('.news-tabs').on('click','li',function(){
            var idx = $(this).index();
            $(this).addClass('active').siblings('.active').removeClass('active');
            $('.news-container ul').eq(idx).show().siblings('ul').hide();
        });
    }

    // 证书查验
    {
        $('.btn-check').click(function(){
            var card = $('.insert-idcard').val(),
            code = $('.insert-code').val();
            if(!card){
                alert('身份证号码不能为空')
                return
            }
            if(!code){
                alert('验证码不能为空')
                return
            }
        });
    }
})();